package com.haima.utils;

import java.security.SecureRandom;
import java.util.stream.Collectors;

public class RandomStringGenerator {
    private static final String CHARACTERS = "ABCDEFGHJKLMNOPQRSTUVWXYZ0123456789";
    private static final SecureRandom RANDOM = new SecureRandom();

//    public static void main(String[] args) {
//        String randomString = generateRandomString(12);
//        System.out.println("生成的随机字符串: " + randomString);
//    }

    public static String generateRandomString(int length) {
        return RANDOM.ints(length, 0, CHARACTERS.length())
                .mapToObj(CHARACTERS::charAt)
                .map(Object::toString)
                .collect(Collectors.joining());
    }
}